#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSettings>

#include "modelaudiofiles.h"
#include "modelplaylists.h"
#include "modelplaylistentries.h"

class QLabel;
class QSortFilterProxyModel;
class TagReaderThread;
class QProgressDialog;
class QPushButton;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    virtual void closeEvent(QCloseEvent *e);

private:
    void loadSettings();
    void saveSettings();
    void loadAudioFiles();
    void loadPlaylists();
    bool checkChanges(Playlist* i_pPlaylist);
    bool savePlaylist(Playlist* i_pPlaylist, bool i_saveAs = false);
    void saveSelectedPlaylists(bool i_saveAs);

private slots:
    void changeMusicPath();
    void openPlaylists();
    void showEntries();
    void enableReplacePath();
    void setReplacePath();
    void createPlaylist();
    void removePlaylist();
    void removeAllPlaylists();
    void savePlaylists();
    void savePlaylistsAs();
    void entriesSelected();
    void removeEntry();
    void refreshEntryId3();
    void showEntriesCount(int i_count);
    void showListsCount(int i_count);
    void readTags();
    void filesSelected();
    void threadStarted();
    void threadFinished();
    void showThreadProgress(int i_done, int i_count);
    void stopThread();

private:
    Ui::MainWindow *ui;
    QLabel* m_pLblStatus;

    QSettings m_settings;
    ModelAudioFiles m_modelAudioFiles;
    ModelPlaylists m_modelPlaylists;
    ModelPlaylistEntries m_modelPlaylistEntries;

    QSortFilterProxyModel* m_pFilesProxy;
    QSortFilterProxyModel* m_pPlaylistsProxy;
    QSortFilterProxyModel* m_pEntriesProxy;

    TagReaderThread* m_pTagThread;
    QProgressDialog* m_pPrgDialog;
    QPushButton* m_pPrgCancelButton;
};

#endif // MAINWINDOW_H
